package edu.hcmus.sow.domain;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import org.codehaus.jackson.annotate.JsonIgnore;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllClients", query = "select myClient from Client myClient"),
		@NamedQuery(name = "findClientByAddress", query = "select myClient from Client myClient where myClient.address = ?1"),
		@NamedQuery(name = "findClientByAddressContaining", query = "select myClient from Client myClient where myClient.address like ?1"),
		@NamedQuery(name = "findClientByCardExpiry", query = "select myClient from Client myClient where myClient.cardExpiry = ?1"),
		@NamedQuery(name = "findClientByCardHolderName", query = "select myClient from Client myClient where myClient.cardHolderName = ?1"),
		@NamedQuery(name = "findClientByCardHolderNameContaining", query = "select myClient from Client myClient where myClient.cardHolderName like ?1"),
		@NamedQuery(name = "findClientByCardNumber", query = "select myClient from Client myClient where myClient.cardNumber = ?1"),
		@NamedQuery(name = "findClientByCardNumberContaining", query = "select myClient from Client myClient where myClient.cardNumber like ?1"),
		@NamedQuery(name = "findClientByCardType", query = "select myClient from Client myClient where myClient.cardType = ?1"),
		@NamedQuery(name = "findClientByCardTypeContaining", query = "select myClient from Client myClient where myClient.cardType like ?1"),
		@NamedQuery(name = "findClientByCity", query = "select myClient from Client myClient where myClient.city = ?1"),
		@NamedQuery(name = "findClientByCityContaining", query = "select myClient from Client myClient where myClient.city like ?1"),
		@NamedQuery(name = "findClientByContactEmail", query = "select myClient from Client myClient where myClient.contactEmail = ?1"),
		@NamedQuery(name = "findClientByContactEmailContaining", query = "select myClient from Client myClient where myClient.contactEmail like ?1"),
		@NamedQuery(name = "findClientByContactFirstName", query = "select myClient from Client myClient where myClient.contactFirstName = ?1"),
		@NamedQuery(name = "findClientByContactFirstNameContaining", query = "select myClient from Client myClient where myClient.contactFirstName like ?1"),
		@NamedQuery(name = "findClientByContactLastName", query = "select myClient from Client myClient where myClient.contactLastName = ?1"),
		@NamedQuery(name = "findClientByContactLastNameContaining", query = "select myClient from Client myClient where myClient.contactLastName like ?1"),
		@NamedQuery(name = "findClientByContactMiddleName", query = "select myClient from Client myClient where myClient.contactMiddleName = ?1"),
		@NamedQuery(name = "findClientByContactMiddleNameContaining", query = "select myClient from Client myClient where myClient.contactMiddleName like ?1"),
		@NamedQuery(name = "findClientByCountry", query = "select myClient from Client myClient where myClient.country = ?1"),
		@NamedQuery(name = "findClientByCountryContaining", query = "select myClient from Client myClient where myClient.country like ?1"),
		@NamedQuery(name = "findClientByCreatedDate", query = "select myClient from Client myClient where myClient.createdDate = ?1"),
		@NamedQuery(name = "findClientByDistrict", query = "select myClient from Client myClient where myClient.district = ?1"),
		@NamedQuery(name = "findClientByDistrictContaining", query = "select myClient from Client myClient where myClient.district like ?1"),
		@NamedQuery(name = "findClientById", query = "select myClient from Client myClient where myClient.id = ?1"),
		@NamedQuery(name = "findClientByName", query = "select myClient from Client myClient where myClient.name = ?1"),
		@NamedQuery(name = "findClientByNameContaining", query = "select myClient from Client myClient where myClient.name like ?1"),
		@NamedQuery(name = "findClientByPhone", query = "select myClient from Client myClient where myClient.phone = ?1"),
		@NamedQuery(name = "findClientByPhoneContaining", query = "select myClient from Client myClient where myClient.phone like ?1"),
		@NamedQuery(name = "findClientByPrimaryKey", query = "select myClient from Client myClient where myClient.id = ?1"),
		@NamedQuery(name = "findClientByStatus", query = "select myClient from Client myClient where myClient.status = ?1"),
		@NamedQuery(name = "findClientByStatusContaining", query = "select myClient from Client myClient where myClient.status like ?1"),
		@NamedQuery(name = "findClientByUpdatedDate", query = "select myClient from Client myClient where myClient.updatedDate = ?1") })
@Table(catalog = "sow", name = "client")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "SharedOnlineWorkspace/edu/hcmus/sow/domain", name = "Client")
@XmlRootElement(namespace = "SharedOnlineWorkspace/edu/hcmus/sow/domain")
public class Client implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "ID", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "NAME", length = 100, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String name;
	/**
	 */

	@Column(name = "ADDRESS", length = 100)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String address;
	/**
	 */

	@Column(name = "DISTRICT", length = 50)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String district;
	/**
	 */

	@Column(name = "CITY", length = 50)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String city;
	/**
	 */

	@Column(name = "COUNTRY", length = 50)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String country;
	/**
	 */

	@Column(name = "PHONE", length = 15)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String phone;
	/**
	 */

	@Column(name = "CONTACT_FIRST_NAME", length = 50)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String contactFirstName;
	/**
	 */

	@Column(name = "CONTACT_MIDDLE_NAME", length = 50)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String contactMiddleName;
	/**
	 */

	@Column(name = "CONTACT_LAST_NAME", length = 50)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String contactLastName;
	/**
	 */

	@Column(name = "CONTACT_EMAIL", length = 30)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String contactEmail;
	/**
	 */

	@Column(name = "CARD_HOLDER_NAME", length = 50)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String cardHolderName;
	/**
	 */

	@Column(name = "CARD_TYPE", length = 20)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String cardType;
	/**
	 */

	@Column(name = "CARD_NUMBER", length = 20)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String cardNumber;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CARD_EXPIRY")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar cardExpiry;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATED_DATE")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar createdDate;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "UPDATED_DATE")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar updatedDate;
	/**
	 */

	@Column(name = "STATUS", length = 3)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String status;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "CREATED_BY", referencedColumnName = "ID") })
	@XmlTransient
	User userByCreatedBy;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "UPDATED_BY", referencedColumnName = "ID") })
	@XmlTransient
	User userByUpdatedBy;
	/**
	 */
	@OneToMany(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.Group> groups;
	/**
	 */
	@OneToMany(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.User> users;
	/**
	 */
	@OneToMany(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.Project> projects;
	/**
	 */
	@OneToMany(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.Forum> forums;
	/**
	 */
	@OneToMany(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.TaskStatus> taskStatuses;
	/**
	 */
	@OneToMany(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.TaskCategory> taskCategories;
	/**
	 */
	@OneToMany(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
	@XmlElement(name = "", namespace = "")
	java.util.Set<edu.hcmus.sow.domain.Folder> folders;
	/**
	 */
	@OneToOne(mappedBy = "client", cascade = { CascadeType.REMOVE }, fetch = FetchType.EAGER)
	@XmlElement(name = "", namespace = "")
	edu.hcmus.sow.domain.Site site;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 */
	public String getAddress() {
		return this.address;
	}

	/**
	 */
	public void setDistrict(String district) {
		this.district = district;
	}

	/**
	 */
	public String getDistrict() {
		return this.district;
	}

	/**
	 */
	public void setCity(String city) {
		this.city = city;
	}

	/**
	 */
	public String getCity() {
		return this.city;
	}

	/**
	 */
	public void setCountry(String country) {
		this.country = country;
	}

	/**
	 */
	public String getCountry() {
		return this.country;
	}

	/**
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 */
	public String getPhone() {
		return this.phone;
	}

	/**
	 */
	public void setContactFirstName(String contactFirstName) {
		this.contactFirstName = contactFirstName;
	}

	/**
	 */
	public String getContactFirstName() {
		return this.contactFirstName;
	}

	/**
	 */
	public void setContactMiddleName(String contactMiddleName) {
		this.contactMiddleName = contactMiddleName;
	}

	/**
	 */
	public String getContactMiddleName() {
		return this.contactMiddleName;
	}

	/**
	 */
	public void setContactLastName(String contactLastName) {
		this.contactLastName = contactLastName;
	}

	/**
	 */
	public String getContactLastName() {
		return this.contactLastName;
	}

	/**
	 */
	public void setContactEmail(String contactEmail) {
		this.contactEmail = contactEmail;
	}

	/**
	 */
	public String getContactEmail() {
		return this.contactEmail;
	}

	/**
	 */
	public void setCardHolderName(String cardHolderName) {
		this.cardHolderName = cardHolderName;
	}

	/**
	 */
	public String getCardHolderName() {
		return this.cardHolderName;
	}

	/**
	 */
	public void setCardType(String cardType) {
		this.cardType = cardType;
	}

	/**
	 */
	public String getCardType() {
		return this.cardType;
	}

	/**
	 */
	public void setCardNumber(String cardNumber) {
		this.cardNumber = cardNumber;
	}

	/**
	 */
	public String getCardNumber() {
		return this.cardNumber;
	}

	/**
	 */
	public void setCardExpiry(Calendar cardExpiry) {
		this.cardExpiry = cardExpiry;
	}

	/**
	 */
	public Calendar getCardExpiry() {
		return this.cardExpiry;
	}

	/**
	 */
	public void setCreatedDate(Calendar createdDate) {
		this.createdDate = createdDate;
	}

	/**
	 */
	public Calendar getCreatedDate() {
		return this.createdDate;
	}

	/**
	 */
	public void setUpdatedDate(Calendar updatedDate) {
		this.updatedDate = updatedDate;
	}

	/**
	 */
	public Calendar getUpdatedDate() {
		return this.updatedDate;
	}

	/**
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 */
	public String getStatus() {
		return this.status;
	}

	/**
	 */
	public void setUserByCreatedBy(User userByCreatedBy) {
		this.userByCreatedBy = userByCreatedBy;
	}

	/**
	 */
	@JsonIgnore
	public User getUserByCreatedBy() {
		return userByCreatedBy;
	}

	/**
	 */
	public void setUserByUpdatedBy(User userByUpdatedBy) {
		this.userByUpdatedBy = userByUpdatedBy;
	}

	/**
	 */
	@JsonIgnore
	public User getUserByUpdatedBy() {
		return userByUpdatedBy;
	}

	/**
	 */
	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}

	/**
	 */
	@JsonIgnore
	public Set<Group> getGroups() {
		if (groups == null) {
			groups = new java.util.LinkedHashSet<edu.hcmus.sow.domain.Group>();
		}
		return groups;
	}

	/**
	 */
	public void setUsers(Set<User> users) {
		this.users = users;
	}

	/**
	 */
	@JsonIgnore
	public Set<User> getUsers() {
		if (users == null) {
			users = new java.util.LinkedHashSet<edu.hcmus.sow.domain.User>();
		}
		return users;
	}

	/**
	 */
	public void setProjects(Set<Project> projects) {
		this.projects = projects;
	}

	/**
	 */
	@JsonIgnore
	public Set<Project> getProjects() {
		if (projects == null) {
			projects = new java.util.LinkedHashSet<edu.hcmus.sow.domain.Project>();
		}
		return projects;
	}

	/**
	 */
	public void setForums(Set<Forum> forums) {
		this.forums = forums;
	}

	/**
	 */
	@JsonIgnore
	public Set<Forum> getForums() {
		if (forums == null) {
			forums = new java.util.LinkedHashSet<edu.hcmus.sow.domain.Forum>();
		}
		return forums;
	}

	/**
	 */
	public void setTaskStatuses(Set<TaskStatus> taskStatuses) {
		this.taskStatuses = taskStatuses;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskStatus> getTaskStatuses() {
		if (taskStatuses == null) {
			taskStatuses = new java.util.LinkedHashSet<edu.hcmus.sow.domain.TaskStatus>();
		}
		return taskStatuses;
	}

	/**
	 */
	public void setTaskCategories(Set<TaskCategory> taskCategories) {
		this.taskCategories = taskCategories;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskCategory> getTaskCategories() {
		if (taskCategories == null) {
			taskCategories = new java.util.LinkedHashSet<edu.hcmus.sow.domain.TaskCategory>();
		}
		return taskCategories;
	}

	/**
	 */
	public void setFolders(Set<Folder> folders) {
		this.folders = folders;
	}

	/**
	 */
	@JsonIgnore
	public Set<Folder> getFolders() {
		if (folders == null) {
			folders = new java.util.LinkedHashSet<edu.hcmus.sow.domain.Folder>();
		}
		return folders;
	}

	/**
	 */
	public void setSite(Site site) {
		this.site = site;
	}

	/**
	 */
	@JsonIgnore
	public Site getSite() {
		return site;
	}

	/**
	 */
	public Client() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Client that) {
		setId(that.getId());
		setName(that.getName());
		setAddress(that.getAddress());
		setDistrict(that.getDistrict());
		setCity(that.getCity());
		setCountry(that.getCountry());
		setPhone(that.getPhone());
		setContactFirstName(that.getContactFirstName());
		setContactMiddleName(that.getContactMiddleName());
		setContactLastName(that.getContactLastName());
		setContactEmail(that.getContactEmail());
		setCardHolderName(that.getCardHolderName());
		setCardType(that.getCardType());
		setCardNumber(that.getCardNumber());
		setCardExpiry(that.getCardExpiry());
		setCreatedDate(that.getCreatedDate());
		setUpdatedDate(that.getUpdatedDate());
		setStatus(that.getStatus());
		setUserByCreatedBy(that.getUserByCreatedBy());
		setUserByUpdatedBy(that.getUserByUpdatedBy());
		setGroups(new java.util.LinkedHashSet<edu.hcmus.sow.domain.Group>(that.getGroups()));
		setUsers(new java.util.LinkedHashSet<edu.hcmus.sow.domain.User>(that.getUsers()));
		setProjects(new java.util.LinkedHashSet<edu.hcmus.sow.domain.Project>(that.getProjects()));
		setForums(new java.util.LinkedHashSet<edu.hcmus.sow.domain.Forum>(that.getForums()));
		setTaskStatuses(new java.util.LinkedHashSet<edu.hcmus.sow.domain.TaskStatus>(that.getTaskStatuses()));
		setTaskCategories(new java.util.LinkedHashSet<edu.hcmus.sow.domain.TaskCategory>(that.getTaskCategories()));
		setFolders(new java.util.LinkedHashSet<edu.hcmus.sow.domain.Folder>(that.getFolders()));
		setSite(that.getSite());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("address=[").append(address).append("] ");
		buffer.append("district=[").append(district).append("] ");
		buffer.append("city=[").append(city).append("] ");
		buffer.append("country=[").append(country).append("] ");
		buffer.append("phone=[").append(phone).append("] ");
		buffer.append("contactFirstName=[").append(contactFirstName).append("] ");
		buffer.append("contactMiddleName=[").append(contactMiddleName).append("] ");
		buffer.append("contactLastName=[").append(contactLastName).append("] ");
		buffer.append("contactEmail=[").append(contactEmail).append("] ");
		buffer.append("cardHolderName=[").append(cardHolderName).append("] ");
		buffer.append("cardType=[").append(cardType).append("] ");
		buffer.append("cardNumber=[").append(cardNumber).append("] ");
		buffer.append("cardExpiry=[").append(cardExpiry).append("] ");
		buffer.append("createdDate=[").append(createdDate).append("] ");
		buffer.append("updatedDate=[").append(updatedDate).append("] ");
		buffer.append("status=[").append(status).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Client))
			return false;
		Client equalCheck = (Client) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
